home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / TKERN091.ZIP / INCLUDE / STDIO.H < prev   
Text File  |  1994-03-11  |  4KB  |  124 lines

  1. /*
  2.  *  This file forms part of "TKERN" - "Troy's Kernel for Windows".
  3.  *
  4.  *  Copyright (C) 1994  Troy Rollo <troy@cbme.unsw.EDU.AU>
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef    __STDIO_H
  22. #define    __STDIO_H
  23.  
  24. #ifndef    NULL
  25. #define    NULL (void *) 0
  26. #endif
  27.  
  28. typedef    struct
  29. {
  30.     int    fd;
  31.     unsigned flags;
  32.     int    modes;
  33.  
  34.     /* Buffering stuff */
  35.  
  36.     unsigned char    ungetchar;
  37.     int    bufsize;
  38.     int    bufidx;
  39.     int    readsize;
  40.     unsigned char    *buffer;
  41. }    FILE;
  42.  
  43. #define    __FL_ERROR    0x0001
  44. #define    __FL_EOF    0x0002
  45. #define    __FL_UNGET    0x0004
  46. #define    __FL_MODIFIED    0x0008
  47. #define    __FL_EMPTY    0x0010
  48. #define    __FL_READ    0x0020
  49. #define    __FL_WRITE    0x0040
  50.  
  51. extern    FILE    _iob[];
  52.  
  53. #define    stdin    &_iob[0]
  54. #define    stdout    &_iob[1]
  55. #define    stderr    &_iob[2]
  56.  
  57. #define    EOF    ((int) -1)
  58.  
  59. /* Buffered I/O functions. We supply these */
  60. /* Input */
  61. extern    int    ungetc(char __c, FILE *__fp);
  62. extern    int    getc(FILE * __fp);
  63. extern    int    scanf(char const *__format, ...);
  64. extern    int    fscanf(FILE *__fp, char const *__format, ...);
  65. extern    int    vfscanf(FILE *__fp, char const *__format, void *__arglist);
  66. extern    char    *fgets(char *__buffer, int __size, FILE *__fp);
  67. extern    char    *gets(char *__buffer);
  68. extern    int    fread(char *__buffer, int __size, int __count, FILE *__fp);
  69.  
  70. /* Output */
  71. extern    int    putc(char __c, FILE *__fp);
  72. extern    int    printf(char const *__format, ...);
  73. extern    int    fprintf(FILE *__fp, char const *__format, ...);
  74. extern    int    vfprintf(FILE *__fp, char const *__format, void *__arglist);
  75. extern    int    fputs(char const *__buffer, FILE *__fp);
  76. extern    int    puts(char const *__buffer);
  77. extern    int    fwrite(char const *__buffer, int __size, int __count, FILE *__fp);
  78.  
  79. /* Open/close */
  80. extern    FILE    *fopen(char const *__filename, char const *__mode);
  81. extern    FILE    *fdopen(int __fd, char const *__mode);
  82. extern    FILE    *freopen(char const *__path, char const *__mode, FILE *__fp);
  83. extern    int    fclose(FILE *__fp);
  84. extern    FILE    *tmpfile(void);
  85.  
  86. /* Positioning */
  87. extern    long    ftell(FILE *__fp);
  88. extern    long    fseek(FILE *__fp, long __offset, int __from);
  89. extern    void    rewind(FILE *__fp);
  90. extern    int    feof(FILE *__fp);
  91. extern    int    ferror(FILE *__fp);
  92.  
  93. /* Buffering */
  94. extern    int    fflush(FILE *__fp);
  95. extern    int    flushall(FILE *__fp);
  96.  
  97. #define    fileno(f)    (f)->fd
  98. #define    _fileno(f)    (f)->fd
  99.  
  100.  
  101. #define    getchar() getc(stdin)
  102. #define    ungetchar() ungetc(stdin)
  103. #define putchar(c) putc(c, stdout)
  104. #define    vprintf(f, v) vfprintf(stdout, f, v)
  105. #define    vscanf(f, v) vfscanf(stdin, f, v)
  106.  
  107. /* Other stdio functions - we expect these to be supplied by the native
  108.  * C library.
  109.  */
  110.  
  111. extern    int    system(char const *__command);
  112. extern    void    perror(char const *__string);
  113. extern    char    *strerror(int __errno);
  114. extern    int    remove(char const *__path);
  115. extern    int    rename(char const *__from, char const *__to);
  116. extern    char    *sscanf(char const *__string, char const *__format, ...);
  117. extern    char    *sprintf(char *__string, char const *__format, ...);
  118. extern    char    *tmpnam(char *__seed);
  119. extern    int    vsprintf(char *__string, char const *__format, void *__arglist);
  120. extern    int    vsscanf(char const *__string, char const *__format, void *__arglist);
  121.          
  122.  
  123. #endif /* __STDIO_H */
  124.